<template>
  <div>
    <Leftbar>
    </Leftbar>
    <headers_copy>

    </headers_copy>
    <el-table class="collection"
              :data="tableData"
              style="width: 100% ">
      <el-table-column type="expand">
        <template slot-scope="props">
          <el-form label-position="left" inline class="demo-table-expand">
            <el-form-item label="博客简介">
              <span>{{ props.row.summary }}</span>
            </el-form-item>
          </el-form>
        </template>
      </el-table-column>
      <el-table-column
          label="博客名称">
        <template slot-scope="props">
          <el-button type="text" @click="getarticle(props.row.aid)"><span content="name">
            {{props.row.title}}
          </span></el-button>
        </template>
      </el-table-column>
      <el-table-column  label="操作" >
        <template slot-scope="scope">
          <el-button
              size="mini"
              type="#f0f9eb"
              @click="Delete(scope.row.aid)">取消收藏</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import Leftbar from "../components/Leftbar";
import headers_copy from "@/components/headers_copy";
import QS from "qs";
const axios = require('axios');
export default {
  name:"Collection",
  components: {
    Leftbar,
    headers_copy
  },
  data() {
    return {
      uid: sessionStorage.getItem("uid"),
      tableData: [],
    }
  },
  created() {
    const _this=this
    axios.get("http://47.107.40.143:8080/myCollect",{params:{uid:this.uid}}).then(res =>{
      _this.tableData=res.data.data
      console.log(res)
    })
  },
  methods: {
    getarticle(s){
      this.$router.push(
          {
            name:'BlogDetail',
            query:{aid:s}
          }
      )
    },
    Delete(s)
    {
      axios.post("http://47.107.40.143:8080/pcOption", QS.stringify(
          {
            aid: s,
            uid: this.uid,
            opt: 1

          })).then(res => {
        console.log(res)
        window.location.reload()
      })
    },
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    }
  }
}
</script>
<style scoped>
.collection{
  margin-left: 250px;
  margin-top: 5px;
}
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}
</style>